package dj.common.lang;

import com.dj.common.DeJiSerializable;
import com.dj.common.response.CentralPageResponse;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

/**
 * <br>
 * <p>分页结果</p>
 *
 * <br>
 *
 * @author ZJG
 * @version 1.0
 * @date 2021/7/10 下午3:26
 */
@Setter
@Getter
@NoArgsConstructor
public class PageResult<T> extends DeJiSerializable {

    private int pageSize;

    private int pageNum;

    private int totalCount;

    private List<T> dataList;

    public void copyTo(CentralPageResponse<T> response) {
        response.setPageNum(pageNum);
        response.setPageSize(pageSize);
        response.setTotalCount(totalCount);
        response.setData(dataList);
    }

    public PageResult(int pageSize, int pageNum) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }

    public PageResult(int pageSize, int pageNum, int totalCount) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
    }

    public PageResult(int pageSize, int pageNum, int totalCount, List<T> dataList) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.dataList = dataList;
    }
}
